{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "import time\n",
    "import pandas as pd\n",
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "from sklearn.model_selection import train_test_split\n",
    "import sys\n",
    "# 将自定义模块所在的目录加入到搜索目录中\n",
    "sys.path.append('../lib/')\n",
    "from lib import text_classification_utils as utils\n",
    "\n",
    "from sklearn import metrics\n",
    "import pandas as pd\n",
    "from keras.layers import Dense, Dropout\n",
    "from keras.models import Sequential\n",
    "from keras.utils.np_utils import to_categorical\n",
    "from keras.preprocessing.text import Tokenizer\n",
    "import keras\n",
    "import numpy as np"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "###  THUCNews数据集"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache C:\\Users\\16287\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 1.122 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    }
   ],
   "source": [
    "data = utils.load_thucnews()\n",
    "THUCNews_data = pd.DataFrame(data, columns=[\"words\", \"sentiment\"])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "                                               words sentiment\n0  马晓旭 意外 受伤 让 国奥 警惕 无奈 大雨 格外 青睐 殷家 军 记者 傅亚雨 沈阳 报...        体育\n1  商瑞华 首战 复仇 心切 中国 玫瑰 要 用 美国 方式 攻克 瑞典 多曼来 了 瑞典 来 ...        体育\n2  冠军 球队 迎新 欢乐 派对 黄旭获 大奖 张军 赢 下 PK 赛 新浪 体育讯 月 日晚 ...        体育\n3  辽足 签约 危机 引 注册 难关 高层 威逼利诱 合同 笑里藏刀 新浪 体育讯 月 日 辽足...        体育\n4  揭秘 谢亚龙 被 带走 总局 电话 骗局 复制 南杨 轨迹 体坛周报 特约记者 张锐 北京 ...        体育",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>words</th>\n      <th>sentiment</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>马晓旭 意外 受伤 让 国奥 警惕 无奈 大雨 格外 青睐 殷家 军 记者 傅亚雨 沈阳 报...</td>\n      <td>体育</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>商瑞华 首战 复仇 心切 中国 玫瑰 要 用 美国 方式 攻克 瑞典 多曼来 了 瑞典 来 ...</td>\n      <td>体育</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>冠军 球队 迎新 欢乐 派对 黄旭获 大奖 张军 赢 下 PK 赛 新浪 体育讯 月 日晚 ...</td>\n      <td>体育</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>辽足 签约 危机 引 注册 难关 高层 威逼利诱 合同 笑里藏刀 新浪 体育讯 月 日 辽足...</td>\n      <td>体育</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>揭秘 谢亚龙 被 带走 总局 电话 骗局 复制 南杨 轨迹 体坛周报 特约记者 张锐 北京 ...</td>\n      <td>体育</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "THUCNews_data.head()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [],
   "source": [
    "THUCNews_copy = THUCNews_data.copy()\n",
    "index_THUCNews = THUCNews_copy['words'].count()\n",
    "for i in range(int(index_THUCNews)):\n",
    "        res = 0\n",
    "        temp = THUCNews_copy['sentiment'][i]\n",
    "        if temp == '体育':\n",
    "            res = 1\n",
    "        elif temp =='娱乐':\n",
    "            res = 2\n",
    "        elif temp =='家具':\n",
    "            res = 3\n",
    "        elif temp =='房产':\n",
    "            res = 4\n",
    "        elif temp =='教育':\n",
    "            res = 5\n",
    "        elif temp =='时尚':\n",
    "            res = 6\n",
    "        elif temp =='时政':\n",
    "            res = 7\n",
    "        elif temp =='游戏':\n",
    "            res = 8\n",
    "        elif temp =='科技':\n",
    "            res = 9\n",
    "        else:\n",
    "            res = 0\n",
    "        THUCNews_copy['sentiment'][i] = res"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [],
   "source": [
    "THUCNews_copy['sentiment'] = THUCNews_copy['sentiment'].astype('int')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [],
   "source": [
    "def data_split(df):\n",
    "    df:pd.DataFrame = df.sample(frac=1.0)\n",
    "    all_labels = df[\"sentiment\"]\n",
    "    all_texts = df[\"words\"]\n",
    "    tokenizer = Tokenizer()\n",
    "    tokenizer.fit_on_texts(all_texts) # 适配文本\n",
    "    sequences = tokenizer.texts_to_sequences(all_texts) #文本序列化为数字\n",
    "    word_index = tokenizer.word_index # 每一个单词都指定一个编号\n",
    "    print('Found %s unique tokens.' % len(word_index))\n",
    "    data = tokenizer.sequences_to_matrix(sequences, mode='tfidf') # 转换成矩阵\n",
    "    labels = to_categorical(np.asarray(all_labels)) # 转换为只有0-1的矩阵\n",
    "    VALIDATION_SPLIT = 0.16\n",
    "    TEST_SPLIT = 0.2\n",
    "    p1 = int(len(data)*(1-VALIDATION_SPLIT-TEST_SPLIT))\n",
    "    p2 = int(len(data)*(1-TEST_SPLIT))\n",
    "    x_train = data[:p1]\n",
    "    y_train = labels[:p1]\n",
    "    x_val = data[p1:p2]\n",
    "    y_val = labels[p1:p2]\n",
    "    x_test = data[p2:]\n",
    "    y_test = labels[p2:]\n",
    "    return x_train,y_train,x_val,y_val,x_test,y_test,word_index,labels"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [],
   "source": [
    "\n",
    "class LossHistory(keras.callbacks.Callback):\n",
    "    def on_train_begin(self, logs={}):\n",
    "        self.losses = {'batch':[], 'epoch':[]}\n",
    "        self.accuracy = {'batch':[], 'epoch':[]}\n",
    "        self.val_loss = {'batch':[], 'epoch':[]}\n",
    "        self.val_acc = {'batch':[], 'epoch':[]}\n",
    "\n",
    "    def on_batch_end(self, batch, logs={}):\n",
    "        self.losses['batch'].append(logs.get('loss'))\n",
    "        self.accuracy['batch'].append(logs.get('acc'))\n",
    "        self.val_loss['batch'].append(logs.get('val_loss'))\n",
    "        self.val_acc['batch'].append(logs.get('val_acc'))\n",
    "\n",
    "    def on_epoch_end(self, batch, logs={}):\n",
    "        self.losses['epoch'].append(logs.get('loss'))\n",
    "        self.accuracy['epoch'].append(logs.get('acc'))\n",
    "        self.val_loss['epoch'].append(logs.get('val_loss'))\n",
    "        self.val_acc['epoch'].append(logs.get('val_acc'))\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [],
   "source": [
    "# 模型很简单，仅有两个全连接层组成，将长度 65604 的 1 维向量经过 2 次压缩成为长度 12 的 1 维向量\n",
    "def mlp_model(x_train,y_train,x_val,y_val,x_test,y_test,word_index,labels):\n",
    "    model = Sequential()\n",
    "    model.add(Dense(512, input_shape=(len(word_index)+1,), activation='relu'))\n",
    "    model.add(Dropout(0.2))\n",
    "    model.add(Dense(labels.shape[1], activation='softmax'))\n",
    "    model.compile(loss='categorical_crossentropy',optimizer='rmsprop',metrics=['acc'])\n",
    "    history = LossHistory()\n",
    "    model.fit(x_train, y_train, validation_data=(x_val, y_val), epochs=2, batch_size=128,callbacks=[history])\n",
    "    res = model.predict(x_test)\n",
    "    res_labels = np.argmax(res,axis=1)  # 获得最大概率对应的标签\n",
    "    y_predict = list(map(int, res_labels))\n",
    "    y_test = np.argmax(y_test,axis=1)  # 获得最大概率对应的标签\n",
    "    y_test= list(map(int, y_test))\n",
    "    precision=metrics.accuracy_score(y_test, y_predict)\n",
    "    recall= metrics.recall_score(y_test, y_predict,average='weighted')\n",
    "    f1= metrics.f1_score(y_test, y_predict,average='weighted')\n",
    "    return history,precision,recall,f1"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 151797 unique tokens.\n"
     ]
    }
   ],
   "source": [
    "thuc_x_train,thuc_y_train,thuc_x_val,thuc_y_val,thuc_x_test,thuc_y_test,thuc_word_index,thuc_labels= data_split(THUCNews_copy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/2\n",
      "50/50 [==============================] - 99s 2s/step - loss: 0.3927 - acc: 0.9184 - val_loss: 0.1598 - val_acc: 0.9706\n",
      "Epoch 2/2\n",
      "50/50 [==============================] - 85s 2s/step - loss: 0.0051 - acc: 0.9995 - val_loss: 0.1914 - val_acc: 0.9663\n"
     ]
    }
   ],
   "source": [
    "history,thuc_precision,thuc_recall,thuc_f1 = mlp_model(thuc_x_train,thuc_y_train,thuc_x_val,thuc_y_val,thuc_x_test,thuc_y_test,thuc_word_index,thuc_labels)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "outputs": [],
   "source": [
    "acc_loss_data = []\n",
    "for i in range(len(history.accuracy['batch'])):\n",
    "    temp = [history.accuracy['batch'][i],history.losses['batch'][i]]\n",
    "    acc_loss_data.append(temp)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "outputs": [],
   "source": [
    "mlp_acc_loss = pd.DataFrame(data=acc_loss_data,columns=['accuracy','loss'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "outputs": [],
   "source": [
    "mlp_acc_loss.to_csv('mlp_acc_loss.csv',index=None)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9645 0.9645 0.9644468638239927\n"
     ]
    }
   ],
   "source": [
    "print(thuc_precision,thuc_recall,thuc_f1)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### IMDB数据集"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "outputs": [],
   "source": [
    "IMDB_data = utils.load_IMDBDatas()\n",
    "IMDB_data.columns = ['words','sentiment']"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "outputs": [
    {
     "data": {
      "text/plain": "                                                   words sentiment\n0      One of the other reviewers has mentioned that ...  positive\n1      A wonderful little production br br The filmin...  positive\n2      I thought this was a wonderful way to spend ti...  positive\n3      Basically there s a family where a little boy ...  negative\n4      Petter Mattei s Love in the Time of Money is a...  positive\n...                                                  ...       ...\n49995  I thought this movie did a down right good job...  positive\n49996  Bad plot bad dialogue bad acting idiotic direc...  negative\n49997  I am a Catholic taught in parochial elementary...  negative\n49998  I m going to have to disagree with the previou...  negative\n49999  No one expects the Star Trek movies to be high...  negative\n\n[50000 rows x 2 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>words</th>\n      <th>sentiment</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>One of the other reviewers has mentioned that ...</td>\n      <td>positive</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>A wonderful little production br br The filmin...</td>\n      <td>positive</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>I thought this was a wonderful way to spend ti...</td>\n      <td>positive</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>Basically there s a family where a little boy ...</td>\n      <td>negative</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>Petter Mattei s Love in the Time of Money is a...</td>\n      <td>positive</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>49995</th>\n      <td>I thought this movie did a down right good job...</td>\n      <td>positive</td>\n    </tr>\n    <tr>\n      <th>49996</th>\n      <td>Bad plot bad dialogue bad acting idiotic direc...</td>\n      <td>negative</td>\n    </tr>\n    <tr>\n      <th>49997</th>\n      <td>I am a Catholic taught in parochial elementary...</td>\n      <td>negative</td>\n    </tr>\n    <tr>\n      <th>49998</th>\n      <td>I m going to have to disagree with the previou...</td>\n      <td>negative</td>\n    </tr>\n    <tr>\n      <th>49999</th>\n      <td>No one expects the Star Trek movies to be high...</td>\n      <td>negative</td>\n    </tr>\n  </tbody>\n</table>\n<p>50000 rows × 2 columns</p>\n</div>"
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "IMDB_data"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "outputs": [],
   "source": [
    "IMDB_copy = IMDB_data.copy()\n",
    "index_IMDB = IMDB_copy['words'].count()\n",
    "for i in range(int(index_IMDB)):\n",
    "        res = 0\n",
    "        temp = IMDB_copy['sentiment'][i]\n",
    "        if temp == 'positive':\n",
    "            res = 1\n",
    "        else:\n",
    "            res = 0\n",
    "        IMDB_copy['sentiment'][i] = res"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "outputs": [],
   "source": [
    "IMDB_copy['sentiment'] = IMDB_copy['sentiment'].astype('int')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "outputs": [],
   "source": [
    "IMDB_copy = IMDB_copy.iloc[0:20000,:]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "outputs": [
    {
     "data": {
      "text/plain": "                                                   words  sentiment\n0      One of the other reviewers has mentioned that ...          1\n1      A wonderful little production br br The filmin...          1\n2      I thought this was a wonderful way to spend ti...          1\n3      Basically there s a family where a little boy ...          0\n4      Petter Mattei s Love in the Time of Money is a...          1\n...                                                  ...        ...\n19995  ok for starters taxi driver is amazing this th...          0\n19996  It s sort of hard for me to say it because I s...          0\n19997  I still liked it though Warren Beatty is only ...          1\n19998  We could still use Black Adder even today Imag...          1\n19999  This so called documentary tries to tell that ...          0\n\n[20000 rows x 2 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>words</th>\n      <th>sentiment</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>One of the other reviewers has mentioned that ...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>A wonderful little production br br The filmin...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>I thought this was a wonderful way to spend ti...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>Basically there s a family where a little boy ...</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>Petter Mattei s Love in the Time of Money is a...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>19995</th>\n      <td>ok for starters taxi driver is amazing this th...</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>19996</th>\n      <td>It s sort of hard for me to say it because I s...</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>19997</th>\n      <td>I still liked it though Warren Beatty is only ...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>19998</th>\n      <td>We could still use Black Adder even today Imag...</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>19999</th>\n      <td>This so called documentary tries to tell that ...</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n<p>20000 rows × 2 columns</p>\n</div>"
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "IMDB_copy"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 68510 unique tokens.\n"
     ]
    }
   ],
   "source": [
    "imdb_x_train,imdb_y_train,imdb_x_val,imdb_y_val,imdb_x_test,imdb_y_test,imdb_word_index,imdb_labels= data_split(IMDB_copy)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n",
      "Model: \"sequential_4\"\n",
      "_________________________________________________________________\n",
      " Layer (type)                Output Shape              Param #   \n",
      "=================================================================\n",
      " dense_8 (Dense)             (None, 512)               35078144  \n",
      "                                                                 \n",
      " dropout_4 (Dropout)         (None, 512)               0         \n",
      "                                                                 \n",
      " dense_9 (Dense)             (None, 2)                 1026      \n",
      "                                                                 \n",
      "=================================================================\n",
      "Total params: 35,079,170\n",
      "Trainable params: 35,079,170\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "Epoch 1/2\n",
      "100/100 [==============================] - 69s 668ms/step - loss: 0.4007 - acc: 0.8444 - val_loss: 0.3028 - val_acc: 0.8807\n",
      "Epoch 2/2\n",
      "100/100 [==============================] - 68s 686ms/step - loss: 0.0804 - acc: 0.9728 - val_loss: 0.4587 - val_acc: 0.8760\n"
     ]
    }
   ],
   "source": [
    "imdb_precision,imdb_recall,imdb_f1 = mlp_model(imdb_x_train,imdb_y_train,imdb_x_val,imdb_y_val,imdb_x_test,imdb_y_test,imdb_word_index,imdb_labels)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.8865 0.8865 0.8864243053740571\n"
     ]
    }
   ],
   "source": [
    "print(imdb_precision,imdb_recall,imdb_f1)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}